package com.chiry.shop.app.controller;

import com.chiry.common.bo.user.UserBO;
import com.chiry.common.vo.Result;
import com.chiry.shop.app.feign.UserFeign;
import com.chiry.shop.app.model.param.BuyParams;
import com.chiry.shop.app.service.BuyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("buy")
public class BuyController {

    @Autowired
    private BuyService buyService;
    @Autowired
    private UserFeign userFeign;

    @PostMapping("submit")
    private Result submitOrder(@RequestBody BuyParams buyParams){
        return buyService.submitOrder(buyParams);
    }

    @PostMapping("userfeign")
    private Result feignUserCall (Long id ){
        Result<UserBO> userById = userFeign.findUserById(id);
        return  Result.success(userById.getData());
    }
}